import request from "@/utils/request";

const api_name = '/course'

export default {
    // 分页查询课程列表数据
    getList(page, limit, searchObj) {
        return request({
            url: `${api_name}/list/${page}/${limit}`,
            method: 'post',
            data: searchObj
        })
    },
    // 根据id删除数据
    delList(id) {
        return request({
            url: `${api_name}/${id}`,
            method: 'delete'
        })
    },
    // 添加课程基本信息
    addCourse(course) {
        return request({
            url: `${api_name}`,
            method: 'post',
            data: course
        })
    },
    // 根据id获取课程基本信息
    getCourseById(id) {
        return request({
            url: `${api_name}/${id}`,
            method: 'get'
        })
    },
    // 更新课程基本信息
    updateCourse(course) {
        return request({
            url: `${api_name}/${course.id}`,
            method: 'put',
            data: course
        })
    },
    // 根据课程id通过api获取发布信息
    getPublishById(id) {
        return request({
            url: `${api_name}/publishinfo/${id}`,
            method: 'get'
        })
    },
    // 发布课程
    publishCourse(id) {
        return request({
            url: `${api_name}/publish/${id}`,
            method: 'put'
        })
    }

}